#!/bin/bash

# 开发环境启动脚本
# Development Environment Startup Script

set -e

echo "💻 启动开发环境..."
echo "================================"

# 获取脚本目录
SCRIPT_DIR="$(dirname "$0")"

# 进入项目根目录
cd "$SCRIPT_DIR/.."

echo "📁 当前目录: $(pwd)"

# 检查是否已有服务在运行
if pgrep -f "nest start" > /dev/null || pgrep -f "umi dev" > /dev/null; then
    echo "⚠️  检测到已有开发服务在运行"
    echo "请先停止现有服务或使用不同的终端窗口"
fi

echo "🗄️  启动数据库服务..."
bash "$SCRIPT_DIR/start-database.sh"

echo ""
echo "🎯 开发环境启动完成！"
echo "================================"
echo "现在请在不同的终端窗口中分别运行："
echo ""
echo "📱 启动前端开发服务器:"
echo "   bash scripts/start-frontend.sh"
echo ""
echo "🔧 启动后端开发服务器:"
echo "   bash scripts/start-backend.sh"
echo ""
echo "📊 启动监控服务 (可选):"
echo "   bash scripts/start-monitoring.sh"
echo ""
echo "💡 提示: 开发模式下前后端需要在不同终端窗口运行以便查看日志"